<?php
/**
 * +-------------------------------------------------------------
 * |Caption:
 * +-------------------------------------------------------------
 * |Author: Lenny
 * +-------------------------------------------------------------
 * |Email:  1685964109@qq.com
 * +-------------------------------------------------------------
 * |Date:   2024-03-04 11:46
 * +-------------------------------------------------------------
 */

namespace app\admin\middleware;
use Closure;
use think\Request;
class CheckDomain
{
    public function handle(Request $request, Closure $next)
    {
        $domain = $request->url();
        // 根据不同的域名来判断访问权限
        if (str_contains($domain, "/admin/upload")) {
            // 可以在这里做出相应处理或者直接调用上传接口
            return $next($request);
        }

        return json(['error' => 'Forbidden'], 403);
    }
}